<script setup>
import { ref, reactive } from 'vue'

// 定义 props
const props = defineProps({
  item: {
    type: Object,
  },
})

// 响应式数据
const radioValue = ref('0')
const activeTriangles = reactive({}) // 存储每个index的显示状态

// 方法定义
const handleTriangle = (index) => {
  // 切换对应index的显示状态
  activeTriangles[index] = !activeTriangles[index]
}

const handleStatusTitle = (id) => {
  // 注意：原代码中使用了未定义的 couponList，这里保持原逻辑结构
  // 实际使用中需要传入 couponList 或从 store 中获取
  if (!window.couponList) return ""

  const coupon = window.couponList.find((item) => item.id === id)
  if (!coupon) return ""

  switch (coupon.status) {
    case 0:
      return "未使用"
    case 1:
      return "已使用"
    case 2:
      return "已失效"
    default:
      return ""
  }
}
</script>
<template>
  <div class="coupon-container">
    <div class="coupon-content">
      <div class="top">
        <div class="left-part">
          <div class="tag">
            <p>会员专属</p>
          </div>

          <div class="info-box">
            <div class="price">
              <p>100</p>
              <div class="yuan">元</div>
            </div>
            <div class="title">洗车体验券</div>
            <div class="subinfo">（满0元可用）</div>
          </div>
          <van-radio-group v-model="radioValue" checked-color="#3758c1" style="margin-right: 3px">
            <van-radio name="1"></van-radio>
          </van-radio-group>
        </div>

      </div>
      <div class="dash"></div>

      <div class="bottom">
        <div class="left">
          <div class="rules-box">
            <div class="rule">规则</div>
            <div class="triangle"></div>
          </div>
        </div>
        <div class="right">
          <p>2025.7.28-2025.8.31</p>
        </div>
      </div>
    </div>
  </div>
</template>



<style lang="less" scoped>
.coupon-content {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 17px 0;
  border-radius: 11px;
  box-shadow: 2px 2px 7px #d6d9dd;

  .top {
    position: relative;
    width: 100%;

    .left-part {
      display: flex;
      justify-content: space-between;
      align-items: baseline;
      position: relative;
      overflow: hidden;

      .tag {
        position: absolute;
        top: 7px;
        left: -67px;
        width: 167px;
        height: 23px;
        background-color: #2b5ac3;
        rotate: -45deg;
        transform-origin: center center;

        p {
          font-size: 10px;
          color: white;
          text-align: center;
          line-height: 23px;
          margin: 0;
        }
      }

      .no-tag {
        background-color: #4e5159;
      }

      .info-box {
        width: 100%;
        display: flex;
        align-items: baseline;
        padding: 17px 0 0 33px;

        .price {
          display: flex;
          align-items: baseline;
          box-sizing: border-box;

          p {
            color: #214186;
            font-weight: 600;
          }

          .yuan {
            width: 20px;
            height: 20px;
            text-align: center;
            line-height: 20px;
            font-size: 10px;
            color: white;
            border-radius: 50%;
            border: 1px solid white;
            background: linear-gradient(to top, #204086, #4c7bcb);
            transform: translateX(-7px);
          }
        }

        .title {
          font-size: 22px;
          color: #224388;
          font-weight: 600;
        }

        .subinfo {
          font-size: 11px;
          color: #517acf;
        }
      }
    }

  }

  .dash {
    width: 95%;
    margin: 3px auto;
    border: 1px dashed #dcdfe1;
  }

  .bottom {
    display: flex;
    justify-content: space-between;
    padding: 5px 17px;

    .left {
      .rules-box {
        display: flex;
        align-items: center;

        .rule {
          color: #696969;
          font-size: 13px;
        }

        .triangle {
          width: 0;
          height: 0;
          border-top: 10px solid #696969;
          border-right: 5px solid transparent;
          border-left: 5px solid transparent;
          margin: 0 7px;
          transition: transform 0.3s ease-in-out;
        }

        .rotated {
          transform: rotate(-180deg);
        }
      }
    }

    .right {
      p {
        font-size: 13px;
        color: #a3a3a3;
      }
    }
  }
}
</style>
